﻿// <copyright file="FittedLinePlot.cs" company="The University of Scranton"> 
// Copyright (c) 2010 All Rights Reserved, http://sdpmt.codeplex.com 
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY  
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
// PARTICULAR PURPOSE. 
// 
// </copyright> 
// <author>Luke Benedict</author> 
// <email>luke.benedict@ieee.org</email> 
// <date>2010-11-22</date> 
// <summary>Contains a static class that facilitates creation of a Fitted Line Plot</summary>
namespace Sdpmt.Coreprocessing
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Sdpmt.Minitabinterface;
    using Sdpmt.Filereader;
    
    public partial class FittedLinePlotUC : UserControl
    {
        /// <summary>
        /// Sets the SortedDictionary that represents the software defect data
        /// </summary>
        internal System.Collections.Generic.IDictionary<DateTime, double> SortedDictionary
        {
            set
            {
                m_SortedDictionary = new SortedDictionary<DateTime,double>(value);
                m_PictureBox.Image = null;

            }
        }
        
        private System.Collections.Generic.IDictionary<DateTime, double> m_SortedDictionary;
        
        public FittedLinePlotUC()
        {
            InitializeComponent();

     
        }

        private void m_FittedLinePlotButton_Click(object sender, EventArgs e)
        {
            MinitabBroker mtb;
            IEnumerable<KeyValuePair<DateTime, double>> list;

            mtb = new MinitabBroker();
            
            m_PictureBox.Image = mtb.GetFittedLinePlot(m_SortedDictionary);

            list = from stuff in m_SortedDictionary
                   select stuff;

            m_FittedLinePlotDataGridView.DataSource = list.ToList();

        }
    }
}
